package com.example.demo.mapper;

import com.example.demo.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.List;

/**
 * @Author: yucsa
 * @Date: 2021/8/22 22:59
 */

@Repository
@Mapper
public interface UserMapper {

    public User findByName(String username);

    public User findById(Long id);

    /**
     * 查询所有用户
     * @return User的list
     */
    //查询所有用户
    public List<User> queryUserList(Integer index , Integer limit);

    /**
     * 添加一个用户，用于注册，但注册只有用户名和密码两个属性，
     * @return 返回加进去的user的id
     */
    public Integer addRegUser(User regUser);

    //更新用户
    public Integer updateUser(User user);

    //删除用户
    public Integer deleteUser(Long id);

    //扣费
    public Integer deduction(Long userId, BigDecimal cost);
}
